/*
 * jpLogin.java
 *
 * Created on 30 de Maio de 2008, 16:00
 */

package Cliente;

/**
 *
 * @author  eriko
 */
public class jpLogin extends javax.swing.JPanel {

    private frmCliente frmcliente;
    /** Creates new form jpLogin */
    public jpLogin(frmCliente frmcliente) {
        this.frmcliente = frmcliente;
        initComponents();
       
        
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jtfUsuario = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        jlAviso = new javax.swing.JLabel();
        jftPorta = new javax.swing.JFormattedTextField();

        jLabel1.setText("Usuário:");

        jLabel2.setText("Porta:");

        jButton1.setText("Entrar");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jlAviso.setFont(new java.awt.Font("Tahoma", 1, 11));
        jlAviso.setForeground(new java.awt.Color(204, 0, 0));
        jlAviso.setText("Entre com os dados...");
        jlAviso.setVisible(false);

        jftPorta.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("#0"))));
        jftPorta.setFocusLostBehavior(javax.swing.JFormattedTextField.PERSIST);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(40, 40, 40)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jtfUsuario, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jButton1)
                            .addComponent(jlAviso)
                            .addComponent(jftPorta, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap(55, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(63, 63, 63)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jtfUsuario, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(12, 12, 12)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(jftPorta, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jlAviso)
                .addGap(9, 9, 9)
                .addComponent(jButton1)
                .addContainerGap(33, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed

    // TODO add your handling code here:
    
    if(!((jtfUsuario.getText().equals(""))||(jftPorta.getText().equals("")))){
        usuario = jtfUsuario.getText();
        porta = Integer.parseInt(jftPorta.getText().replaceAll(" ", ""));
        this.setVisible(false);
        frmcliente.jpPainel.setVisible(true);
        frmcliente.getContentPane().add(frmcliente.jpPainel, java.awt.BorderLayout.PAGE_END);
    }else {
        jlAviso.setVisible(true);
    }
    
}//GEN-LAST:event_jButton1ActionPerformed

   
    public int getPorta() {
        return porta;
    }

    public String getUsuario() {
        return usuario;
    }
   
    private int porta;
    private String usuario;
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JFormattedTextField jftPorta;
    private javax.swing.JLabel jlAviso;
    private javax.swing.JTextField jtfUsuario;
    // End of variables declaration//GEN-END:variables

}
